package shims

import "utf8"
import "substr"

//Split a utf8 encoded string into its runes
var Runes FreeFinder = func(s []byte, n int) *substr.S {
	if n < 0 {
		n = utf8.RuneCount(s)
	}
	out := substr.New(s, n)
	for i := 0; i < n || i < len(s); {
		_, width := utf8.DecodeRune(s[i:])
		out.Push(i, i+width)
		i += width
	}
	return out
}
